/**
 * 
 */
package com.suyx.job.utils.mh;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.suyx.job.utils.ScreenCapture;

/**
 * @author syx
 *
 */
@Component
public class CsjwScene {

	@Autowired
	private WaTuUtils waTuUtils;
	
	public final static Map<String,String> options_x = new HashMap<>();  
	public final static Map<String,String> options_y = new HashMap<>();
	static {  
		options_x.put("0", "757 331");  
		options_x.put("1", "458 225");  
		options_x.put("2", "550 228");
		options_x.put("3", "655 226"); 
		options_x.put("4", "458 330");
		options_x.put("5", "554 330");
		options_x.put("6", "651 330");
		options_x.put("7", "452 427");
		options_x.put("8", "553 427");
		options_x.put("9", "660 427");
		
		options_y.put("0", "889 328");  
		options_y.put("1", "589 233");  
		options_y.put("2", "690 233");
		options_y.put("3", "783 233"); 
		options_y.put("4", "583 327");
		options_y.put("5", "685 327");
		options_y.put("6", "785 327");
		options_y.put("7", "587 424");
		options_y.put("8", "688 424");
		options_y.put("9", "787 424");
	} 
	
	public  void csjw(String device ,String zuobiao,String baoguo) throws Exception{
		//打开包裹
		ScreenCapture.mouseClick(device, "1308 675");
		ScreenCapture.mouseClick(device, "809 212");// 打开长寿
		ScreenCapture.mouseClick(device, "522 422");// 使用
		ScreenCapture.mouseClick(device, "908 646");//7到到长寿到长寿郊外的口子
		ScreenCapture.mouseClick(device, "1156 52");// 关闭包裹
		ScreenCapture.mouseClick(device, "1231 617");// 到长寿郊外的口子
	}
	
	public  void csjwSceneSame(String device,String zuobiao,String baoguo) throws Exception{
		Thread.sleep(2 * 1000L);
		ScreenCapture.mouseClick(device, "117 68");//打开地图
        ScreenCapture.mouseClick(device, "466 121");// 选x坐标
        String x = zuobiao.split(" ")[0];
        String y = zuobiao.split(" ")[1];
        input_x(device,x);
        ScreenCapture.mouseClick(device, "754 430");
        ScreenCapture.mouseClick(device, "610 103"); // 选y坐标
        input_y(device, y);
        ScreenCapture.mouseClick(device, "888 424");
        ScreenCapture.mouseClick(device, "760 109");  // 前往
        ScreenCapture.mouseClick(device, "1053 84"); //关闭地图
        //开始挖图
        waTuUtils.startWatu(device, zuobiao, baoguo);
	}
	
	private void input_x(String device,String x){
		for(int i =0;i<x.length();i++){
			char c = x.charAt(i);
			String x_zb = options_x.get(String.valueOf(c));
			ScreenCapture.mouseClick(device, x_zb);
		}
	}
	
	private void input_y(String device,String y){
		for(int i =0;i<y.length();i++){
			char c = y.charAt(i);
			String y_zb = options_y.get(String.valueOf(c));
			ScreenCapture.mouseClick(device, y_zb);
		}
	}
}
